package com.aletto.general_store.ui.activities.orders;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.aletto.general_store.R;
import com.aletto.general_store.data.model.OrderItem;
import com.aletto.general_store.presenters.OrderCancelArbitrationTask;
import com.aletto.general_store.presenters.ConsumerOrderDetailsTemplate;
import com.aletto.general_store.presenters.OrderRaiseArbitrationTask;
import com.aletto.general_store.utils.XHelper;

/**
 * 我的交易：待发货,详情
 */
public class OrderConsumerDeliveryActivity extends AppCompatActivity {

    public static Intent newIntent(Context context, OrderItem item) {
        Intent intent = new Intent(context, OrderConsumerDeliveryActivity.class);
        intent.putExtra("ITEM", item);
        return intent;
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_delivery_details);

        OrderItem item = (OrderItem) getIntent().getSerializableExtra("ITEM");
        long id = item.getOrderId();
        long contractId = item.getBtc_order_id();

        ViewGroup layout_parent = findViewById(R.id.layout_parent);
        View tv_store_delivery = findViewById(R.id.tv_store_delivery);

        XHelper.initTitle(this, R.string.order_delivery_details);

        // 详情
        new ConsumerOrderDetailsTemplate(String.valueOf(id), layout_parent).execute(getLifecycle());

        // 退款
        tv_store_delivery.setOnClickListener(v -> new OrderRaiseArbitrationTask(contractId).execute(getLifecycle()));
    }

}
